package com.ben.springbootcache.controller;

import com.ben.springbootcache.pojo.User;
import com.ben.springbootcache.service.UserService;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;


    @RequestMapping(value = "/findById/{id}",method = RequestMethod.GET)
    public User findById(@PathVariable("id") Integer id){
       return userService.findById(id);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public User updateUser(@RequestBody User user){
        return userService.updateUser(user);
    }

    @RequestMapping(value = "/delete/{id}",method = RequestMethod.GET)
    public void deleteUser(@PathVariable("id") Integer id){
        userService.deleteUserById(id);
    }
}
